#!/usr/bin/python
# vim:fileencoding=utf8
"""
Описывает класс мысли =).
"""

from gnTai.usefull_staff.textprocess import *
from gnTai.words.specialverb import to_be as _to_be
from gnTai.words.specialverb import to_do as _to_do

class Thought():
    """
    Класс мысль.
    """
    
    def __init__(self, subject=None, action=None):
        #Подлежащее Тип Object
        self.subject = subject
        #Сказуемое
        self.action = action
        ##Обстоятельство
        #self.modifier = None

        #Является ли вопросом
        self.question = False


    def set_subject(self, subject):
        self.subject = subject

    def set_action(self, action):
        self.action = action
        return self

    def set_question(self, qst):
        self.question = qst
        return self

    def get_action_form(self):
        """
        Возвращает словарь --- форму глагола.
        """
        res = {'person':3, 'plurum':self.subject.plurum}
        return res
    
    def __str__(self):
        return self.to_string()
    
    
    def to_string(self):
        """
        """
        if self.question:
            return self.__question_to_string()
        else:
            return self.__story_to_string()
                             
                             
                             
    def __question_to_string(self):
        if self.action.word is _to_be:
            return words2text([_to_be.to_string(**self.get_action_form()),
                             self.subject.to_string(),
                             self.action.to_string(question=True)
                             ]).capitalize() + '?'
        else:
            return  words2text([_to_do.to_string(**self.get_action_form()),
                            self.subject.to_string(),
                            self.action.to_string()
                            ]).capitalize() + '?' 


    def __story_to_string(self):
        return words2text([self.subject.to_string(),
                         self.action.to_string(**self.get_action_form())
                         ]).capitalize() + '.'
